package com.pms.controller;

import com.pms.dto.ComplaintPageQueryDTO;
import com.pms.dto.ComplaintSaveDTO;
import com.pms.dto.RepairPageQueryDTO;
import com.pms.result.PageResult;
import com.pms.result.Result;
import com.pms.service.ComplaintService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "投诉相关接口")
@RestController
@RequestMapping("/complaint")
@Slf4j
public class ComplaintController {

    @Autowired
    private ComplaintService complaintService;

    @ApiOperation("新增投诉")
    @PostMapping("/save")
    public Result<String> save(@RequestBody ComplaintSaveDTO complaintSaveDTO){
        log.info("新增投诉,{}",complaintSaveDTO);
        complaintService.save(complaintSaveDTO);
        return Result.success();
    }

    @ApiOperation("投诉分页查询")
    @GetMapping("/page")
    public Result<PageResult> page(ComplaintPageQueryDTO complaintPageQueryDTO){
        log.info("投诉分页查询,{}",complaintPageQueryDTO);
        PageResult pageResult=complaintService.page(complaintPageQueryDTO);
        return Result.success(pageResult);
    }

    @ApiOperation("批量删除")
    @DeleteMapping("/delete")
    public Result<String> deleteBatch(@RequestParam List<Integer> ids){
        log.info("批量删除，{}",ids);
        complaintService.deleteBatch(ids);
        return Result.success();
    }

    
}
